package com.trkj.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.jpa.IjlregisterDAO;
import com.trkj.pojos.JlRegistration;


@Service
@Transactional
public class JlregistrationService {

	@Autowired
	private IjlregisterDAO registerDAO;
	
	//根据名字查找
    public List<JlRegistration> findbyaddres(long ireId){
		List<JlRegistration> list=registerDAO.findByregisid(ireId);
		return list;
	}
    /*
	 * 查看挂号信息
	 */
	public Map<String, Object> queryreginByPage(int page, int rows){
		PageRequest pr = new PageRequest(page - 1, rows);
		//获取当前页的记录
		List<JlRegistration> list = registerDAO.findreginByPage(pr);
		//获取总的记录条数
		long total = registerDAO.count();		
		Map<String, Object> map = new HashMap<>();
		map.put("total", total);
		map.put("rows", list);
		return map;
	}
	public void addregin(JlRegistration s){
		registerDAO.save(s);
	     }
	//批量删除学生
			public void delregin(Long[] reId){
				for(int i=0;i<reId.length;i++){
					registerDAO.delete(reId[i]);
				}				
		} 

		//根据性别查找
		public List<JlRegistration> findbyreks(String sex){
			List<JlRegistration> list=registerDAO.findbyreks(sex);
		    return list;
		}  
		//根据名字查找
		public List<JlRegistration>  findbyreys (String sex){
			List<JlRegistration> list=registerDAO.findbyreys(sex);
			return list;
		}
		//根据地址查找
		public List<JlRegistration> findbyrefs (String sex){
			List<JlRegistration> list=registerDAO.findbyrefs(sex);
			return list;
		}
		//根据身份证查找
		public List<JlRegistration>  findbyrejf(String sex){
			List<JlRegistration> list=registerDAO.findbyrejf(sex);
			return list;
		}
		//查找最大的日期findMaxreghjhByPage
		public Date findMaxregtimByPage(){			
			return registerDAO.findMaxregtimByPage();
		}
		//查找最大的呼叫号
		public BigDecimal findMaxreghjhByPage(){			
			return registerDAO.findMaxreghjhByPage();
		}
		//查找最小的呼叫号
		public BigDecimal findminreghjhByPage(){			
			return registerDAO.findminreghjhByPage();
		}
		//根据呼叫号查询卡号findbyregin
		public BigDecimal findbyIreId(BigDecimal callnum){			
			return registerDAO.findbyIreId( callnum);
		}
		//根据呼叫号查询卡号
		public JlRegistration findbyregin(BigDecimal callnum){			
			return registerDAO.findbyregin( callnum);
		}
		
}
